package comp353Games;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.*;

/**
 * NimDisplay.java Offers the visual presentation of the game of Nim.
 *
 * @author Andre Harvey, Deanna Fink, Tyler Radley
 * @version 3/25/12
 */
public class NimDisplay extends JPanel {

    //instance variables
    //The Nim game this will display.
    private Nim game;

    /**
     * Class constructor.
     *
     * @param game The Nim instance this will display.
     */
    public NimDisplay(GameModel game) {
        super(new BorderLayout());
        this.game = (Nim) game;
        this.setOpaque(true);
    }

    @Override
    protected void paintComponent(Graphics graphics) {
        graphics.setColor(Color.BLACK);
        for (int i = 0; i < this.game.heapsClone().length; i++) {
            for (int j = 0; j < game.heapsClone()[i]; j++) {
                graphics.fillRect(j * 20 + 10, i * 70 + 10, 10, 50);
            }
        }
    }

    @Override
    public Dimension getPreferredSize() {
        int width = 610;
        int height = 512;
        return new Dimension(width, height);
    }

    /**
     * Returns the preferred size for the status bar.
     *
     * @return A Dimension object representing the smallest size needed to
     * nicely display the status bar.
     */
    public Dimension getStatusBarPreferredSize() {
        int width = 600;
        int height = 50;
        return new Dimension(width, height);

    }
}